package com.desire.controller.purchase;

import com.desire.bean.common.PageBean;
import com.desire.bean.common.ResultBean;
import com.desire.bean.purchase.Apply;
import com.desire.controller.common.BaseController;
import com.desire.service.purchase.ApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author LittleDesire
 * @description
 * @date 2022-05-21 周六 11:05
 * @since 17
 */
@RestController
@Api(tags = "采购申请")
@RequestMapping("/api/purchase/apply")
public class ApplyController extends BaseController {
    @Autowired
    ApplyService applyService;

    @ApiOperation("保存采购申请单")
    @PostMapping("/save")
    public ResultBean save(@RequestBody @Validated Apply apply) {
        int rs = applyService.save(apply);
        return saveResult(rs);
    }

    @ApiOperation("查询采购申请单列表")
    @PostMapping("/query")
    public ResultBean query(@RequestBody @Validated Map<String, Object> map) {
        PageBean pageBean = applyService.query(map);
        return success("采购申请单列表", pageBean);
    }

    @ApiOperation("查询采购申请单明细")
    @GetMapping("/get")
    public ResultBean get(String id) {
        Apply apply = applyService.get(id);
        return success("采购申请单明细", apply);
    }
}
